package org.an.proj.contacts.model.vo;

import java.util.Map;
import org.an.proj.contacts.util.SchemeUtil;

/**
 * Created by Fcy on 2016/11/4.
 * urlScheme格式：
 * scheme://h5/newhouse?type=customer&title=你好&url=https%3a%2f%2fwww.baidu.com%2f
 */
public class URL {
  private String scheme;

  private String action;

  private Map<String, String> params;

  /**
   * @return null if actionUrl is invalid
   */
  public static URL parse(String actionUrl) {
    String scheme = SchemeUtil.getScheme(actionUrl);
    if (scheme == null) return null;

    URL url = new URL();
    url.scheme = scheme;
    url.action = SchemeUtil.getAction(actionUrl);
    url.params = SchemeUtil.getParams(actionUrl);
    return url;
  }

  public String getScheme() {
    return scheme;
  }

  public String getAction() {
    return action;
  }

  public Map<String, String> getParams() {
    return params;
  }
}
